<html>
<head><meta charset="utf-8"><title>side-channel fuzzing · wg-secure-code · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/index.html">wg-secure-code</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html">side-channel fuzzing</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="162758112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162758112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162758112">(Apr 07 2019 at 14:52)</a>:</h4>
<p>Hi everyone,</p>
<p>I was wondering if anyone has looked into using fuzzing to detect side-channel vulnerabilities, and if there would be any interest in this group in pursuing that? </p>
<p>The basic idea is to split your fuzzing input into two parts, and run the two input-parts against your program.  The fitness function of the fuzzer is then modified so that, in addition to coverage, it's also trying to maximize the difference in time, memory, and instructions between the two input parts.  The research suggests that this can find real-world timing vulnerabilities.  More information on the research can be found here: <a href="https://arxiv.org/abs/1811.07005" target="_blank" title="https://arxiv.org/abs/1811.07005">https://arxiv.org/abs/1811.07005</a></p>



<a name="162766228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162766228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DevQps <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162766228">(Apr 07 2019 at 18:10)</a>:</h4>
<p>Sounds cool! I have never tried it! But there might be some others who did! Even though I never saw anything like this pass here.</p>



<a name="162787383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162787383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162787383">(Apr 08 2019 at 03:55)</a>:</h4>
<p>Note that this can detect only a limited set of side-channel vulnerabilities. It's a worthwhile task, but won't catch things like Hamming-weight-based vulnerabilities.</p>



<a name="162796806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162796806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162796806">(Apr 08 2019 at 07:59)</a>:</h4>
<p>This seems much alike to <a href="https://eprint.iacr.org/2016/1123.pdf" target="_blank" title="https://eprint.iacr.org/2016/1123.pdf">dudeCT</a> statistical tests. dudeCT is also based on a two input-part approach, where you flip a coin for each part whether it should be random or not (you can surely also randomize lengths to test for padding-based timing side channels, instead of just comparisons though I haven't done that myself yet). DifFuzz, at first glance, also seems limited to timing-based side-channel vulnerabilities (please correct me if I'm wrong), and I can't quite tell why I should use that instead of dudeCT. Is there something I've missed?</p>



<a name="162797139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162797139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162797139">(Apr 08 2019 at 08:04)</a>:</h4>
<p>Edit: I'm interested in this. I've been working on some side-channel testing myself for a library, and maybe I could use this for testing as well.</p>



<a name="162841699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162841699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162841699">(Apr 08 2019 at 18:15)</a>:</h4>
<p>I could be wrong, but I think the main difference is that for dudeCT you need to hand-craft the input variables and it will tell you if there is a statistical difference between the two runs.  With DiffFuzz, the inputs are dynamically discovered using a genetic algorithm.   I think you could combine dudeCT and DiffFuzz together where DiffFuzz is used to find the inputs, and then dudeCT screens the results of DiffFuzz to determine wether the results are "real" or just statistical noise.</p>



<a name="162842253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162842253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162842253">(Apr 08 2019 at 18:23)</a>:</h4>
<p><span class="user-mention" data-user-id="126966">@brycx</span>, I'm considering going ahead and building a proof-of-concept crate that uses a genetic-algorithm crate (there seems to be a few good options out there) and PAPI (<a href="https://github.com/LutzCle/papi-rs" target="_blank" title="https://github.com/LutzCle/papi-rs">https://github.com/LutzCle/papi-rs</a>).  If you're interested in this space as well, it might be worth while coordinating on approach before I get too deep into it.</p>



<a name="162844322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162844322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162844322">(Apr 08 2019 at 18:47)</a>:</h4>
<p>Then it's somewhat in the lines of what I suspected. I still don't know whether it is limited to timing side-channels or if it could measure anything else. I actually thought about whether it was something to be combined, because finding input for dudeCT that produces the largest t-values could be handy. On the other hand, some crypto algorithms are very straightforward to craft such inputs for, such as comparisons. I'm not familiar with PAPI, but the crate seems to only support (only tested on) Linux of the major platforms. If DifFuzz only supports timing-based side-channels, it would be a shame to limit the fuzzer to only Linux machines (if the crate doesn't work on other major platforms), when the CPU's cycle counter could just as well have been used.</p>
<p>This would be my first time being involved building something like this, so it's probably best if you just go ahead on the PoC. This way I can follow along and get a more solid understanding of what this project would consist of. I'm still happy to discuss it though.</p>



<a name="162844459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162844459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162844459">(Apr 08 2019 at 18:49)</a>:</h4>
<p>Also for dudect, you don't actually need to hand-craft, you can use random ones as well. I'm sure hand-crafted work better in some instances though.</p>



<a name="162845079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162845079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162845079">(Apr 08 2019 at 18:57)</a>:</h4>
<p><span class="user-mention" data-user-id="126966">@brycx</span> , thanks for your input.   I would opt to use PAPI mainly because my skillset is not very well suited to low-level work.  I'll try to get the prototype working with PAPI, then open it up to other contributors who might have the skillset to interface with the hardware more directly.  I'll let the group here know when I have something working.  :)</p>



<a name="162845851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162845851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> brycx <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162845851">(Apr 08 2019 at 19:07)</a>:</h4>
<p>No problem, and that's understandable. Looking forward to it!</p>



<a name="162847727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/162847727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cem Karan <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#162847727">(Apr 08 2019 at 19:33)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="126966">brycx</span> , thanks for your input.   I would opt to use PAPI mainly because my skillset is not very well suited to low-level work.  I'll try to get the prototype working with PAPI, then open it up to other contributors who might have the skillset to interface with the hardware more directly.  I'll let the group here know when I have something working.  :)</p>
</blockquote>
<p>I would actually suggest that you keep using papi-rs for as long as you possibly can; no need to reinvent the wheel when someone is giving a perfectly good one!</p>



<a name="163767408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/163767408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#163767408">(Apr 19 2019 at 21:33)</a>:</h4>
<p>Hi everyone,</p>
<p>I wanted to give an update on fuzzing for side-channel vulnerabilities. </p>
<p>I've got a basic proof-of-concept up and running here: <br>
<a href="https://github.com/phayes/sidefuzz" target="_blank" title="https://github.com/phayes/sidefuzz">https://github.com/phayes/sidefuzz</a></p>
<p>I've got a few example fuzzing targets here:<br>
<a href="https://github.com/phayes/sidefuzz-targets" target="_blank" title="https://github.com/phayes/sidefuzz-targets">https://github.com/phayes/sidefuzz-targets</a></p>
<p>Summary: It works!   It can successfully tell the difference between constant-time and non-constant time functions by fuzzing inputs.     It operates in two steps:</p>
<p>Step 1. Use a genetic algorithm to find candidate input pairs that look like they might have large differenced in timing (similar to DiffFuzz)<br>
Step 2. Uses statistics to check t-values to confirm that there is <em>really</em> a difference (similar to DudeCT). </p>
<p>Right now I'm counting cpu-cycles as my primary measurement.   It should work on all x64 platforms.   Using cpu-cycles is a bit noisy, so I still want to use PAPI behind a feature-flag for linux users.    Please take it for a run and give feedback. There's still lots of cleanup to do in terms of documentation etc etc.</p>



<a name="163767631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/163767631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#163767631">(Apr 19 2019 at 21:37)</a>:</h4>
<p>The next steps are:</p>
<p>1. Clean up the code and document. <br>
2. Start making fuzzing-targets against real crates!</p>



<a name="163788886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/163788886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DevQps <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#163788886">(Apr 20 2019 at 06:07)</a>:</h4>
<p>That sounds pretty cool! Good work man! I hope I can give it a try somewhere today and report back here!</p>



<a name="163858370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/163858370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DevQps <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#163858370">(Apr 21 2019 at 16:37)</a>:</h4>
<p>I took another look at the README and stuff like that! I think it really looks good! The targets repository is nice as well.<br>
Just the other day I created a list of Rust related security projects here: <a href="https://github.com/rust-secure-code/rustsec-projects" target="_blank" title="https://github.com/rust-secure-code/rustsec-projects">https://github.com/rust-secure-code/rustsec-projects</a></p>
<p>If you want I can add your fuzzer here as well? Or if you want you can create a PR / issue yourself on that repo :)</p>
<p>Keep the good work up at least!</p>



<a name="163866056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/163866056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#163866056">(Apr 21 2019 at 20:23)</a>:</h4>
<p>Is the motivation that no such tool currently exists for any language, or just for Rust? Or is it something I've missed?</p>



<a name="163875710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/163875710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#163875710">(Apr 22 2019 at 01:00)</a>:</h4>
<p>There’s a similar tool for Java here: <a href="https://github.com/isstac/diffuzz" target="_blank" title="https://github.com/isstac/diffuzz">https://github.com/isstac/diffuzz</a></p>
<p>However, SideFuzz is not a strict port of the above, and is trying to combine the best parts of both Java’s DiffFuzz and dudect.  In that regard it might be unique.</p>



<a name="164561533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/164561533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#164561533">(Apr 30 2019 at 18:12)</a>:</h4>
<p>Hi all, </p>
<p>Another update on side-channel fuzzing. </p>
<p>You can check out the sidefuzz tool here: <a href="https://github.com/phayes/sidefuzz" target="_blank" title="https://github.com/phayes/sidefuzz">https://github.com/phayes/sidefuzz</a></p>
<p>It is "basically done" modulo a few minor improvements and publishing to <a href="http://crates.io" target="_blank" title="http://crates.io">crates.io</a> .  I made a major pivot in the architecture of the whole thing.  Instead of counting CPU cycles, it now requires that targets be compiled to wasm, and counts individual instructions as it executes the target inside a wasm interpreter.   This has some advantages and disadvantages:</p>
<p>1. Major advantage is that using wasm makes the fuzzer WAY more accurate.   It is now easily able to pick out side-channel vulnerabilities, and consistently evolves inputs that maximize timing differences. More importantly, there are no more false-positives.  It works exactly as it should, and it works really well. <br>
2. Major disadvantage is that we now require the targets to compile to wasm.  Targets like ring don't compile to wasm, so we can't fuzz them.  However, I expect this disadvantage to slowly diminish over time as more and more cryptography crates add wasm support. <br>
3. Bonus: we can now fuzz non-rust code for side-channel vulnerabilities. Go, C, and C++ can all be used with sidefuzz if they can compile to wasm.<br>
Please take a look at provide feedback.  The tool has already found it's first side-channel vulnerability, and I will be reporting that to it the relevant crate shortly.</p>



<a name="164571138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/164571138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick D Hayes <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#164571138">(Apr 30 2019 at 19:56)</a>:</h4>
<p>Fist potential side-channel vulnerability found reported: <a href="https://github.com/RustCrypto/RSA/issues/19" target="_blank" title="https://github.com/RustCrypto/RSA/issues/19">https://github.com/RustCrypto/RSA/issues/19</a></p>



<a name="164614608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/side-channel%20fuzzing/near/164614608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DevQps <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/side-channel.20fuzzing.html#164614608">(May 01 2019 at 10:39)</a>:</h4>
<p>Sounds cool! Let's hope most projects make the transition to WASM such that we can fuzz most things.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>